{extend name="base/common"}

{block name="style"}
<link rel="stylesheet" href="/static/ztree/zTreeStyle.css">
<style>
    .wrapper-content .row {background: #fff;border: 1px solid #e7eaec;margin: 0;}
    .row .mail-box-header {border: none;}
    .ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
    .tree-box {background: #fff;padding-bottom: 20px}
    .folder-box {height: 100%;background: #fff;padding: 30px 20px 20px 20px;}
    .ztree * {font-size: 14px;font-family: "Microsoft Yahei", "Helvetica Neue", Helvetica, Arial, sans-serif}
    .ztree li {line-height: 18px;}
    .ztree li a {height: 20px !important;}
    .files-box {height: 100%;background: #fff;padding: 30px 20px 20px 20px;}
    .files-box .title {display: flex;justify-content: space-between;}
    .files-box .title > p, .folder-box .title > p {font-size: 16px;}
    .file-list {margin-top: 10px;}
    .file-list table.table-mail tr td {padding: 10px 8px;}
    .modal-dialog {margin-top: 30%;text-align: center;}
    .file-name {width: calc(100% - 80px);white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: inline-block;text-align: left;float: left;}
</style>
{/block}

{block name="page-header"}

{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="mail-box-header">
                <h2>资源中心 / 文件夹管理</h2>
            </div>
        </div>
        <div class="col-lg-3" style="height: 100%;padding-right: 0;">
            <div class="form-group folder-box">
                <div class="title">
                    <p>文件夹管理</p>
                </div>
                <div class="tree-box">
                    <ul id="treeDemo" class="ztree"></ul>
                </div>
            </div>

        </div>
        <div class="col-lg-9" style="height: 100%;padding-left: 0;">
            <div class="files-box">
                <div class="title">
                    <p>文件列表</p>
<!--                    <button type="submit" class="btn btn-sm btn-primary add-file">添加</button>-->
                    <a data-toggle="modal" class="btn btn-primary add-file" href="#modal-form">添加文件</a>
                </div>
                <div class="file-list">
                    <table class="table table-hover table-mail">
                        <thead>
                        <tr>
                            <th>文件标题</th>
                            <th>文件类型</th>
                            <th>上传时间</th>
                            <th>文件大小</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody id="file-list">
<!--                        <tr>-->
<!--                            <td>阿迪去玩的起我的困难</td>-->
<!--                            <td>撒大堆袜的</td>-->
<!--                            <td>2019-01-01</td>-->
<!--                            <td>19</td>-->
<!--                            <td>-->
<!--                                <a href="" class="confirm btn-sm btn-primary" onclick="editFile()"><i class="fa fa-pencil"></i> 修改</a>-->
<!--                                <a href="" class="confirm btn-sm btn-danger ajax-del"><i class="fa fa-trash-o"></i> 删除</a>-->
<!--                            </td>-->
<!--                        </tr>-->
                        </tbody>
                        <tfoot>
                        <tr>

                        </tr>
                        </tfoot>
                    </table>
                </div>
                <div class="page">
                    <ul class="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
    <div id="modal-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <form class="form-horizontal" id="form" method="post">
                        <p class="tt" id="modal-title">添加文件</p>
                        <div class="form-group">
                            <div class="row">
                                <div class="col-lg-2 col-sm-2 no-padding text-right" style="text-align:right;line-height:30px;margin-bottom: 10px">
                                    <label>文件标题:</label>
                                </div>
                                <div class="col-lg-10 col-sm-10 sel" style="padding-right:35px;">
                                    <input type="text" placeholder="请输入文件标题" class="form-control form_title" name="title">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-2 col-sm-2 no-padding text-right" style="text-align:right;line-height:30px;margin-bottom: 10px">
                                    <label>文件:</label>
                                </div>
                                <div class="col-lg-10 col-sm-10 sel" style="padding-right:35px;">
                                    <div id="input-file" class="form-control form_title">
                                        <span class="file-name"></span>
                                        <button class="btn-sm btn-primary post-put" type="button" id="addFile" style="float: right;margin: -5px -12px 0 0;">添加文件</button>
                                    </div>
                                    <input type="file" name="attachment" id="file" style="display: none;" accept="image/*,application/msword, application/vnd.ms-powerpoint, application/pdf, application/pdf, application/zip,application/x-zip,application/x-zip-compressed, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.wordprocessingml.document">
                                </div>

                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button class="btn btn-primary post-put" type="button" target-form="form-horizontal" id="addForm">添加</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="myModal">
        <div class="modal-dialog modal-sm">
            <img alt="" src="/admin/images/loading.gif" />
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="/static/ztree/jquery.ztree.all.min.js"></script>
<script src="/admin/js/bootstrap-paginator.js"></script>
<script>
    highlight_subnav("{:Url('Resource/folder')}");

    $(function () {
        console.log({$department})
        console.log({$user_data})
        var user = {$user_data};
        var zTreeObj, fileObj = {id:0};
        // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
        var setting = {
            view: {
                addHoverDom: addHoverDom,
                removeHoverDom: removeHoverDom,
                selectedMulti: false
            },
            edit: {
                enable: true,
                editNameSelectAll: true,
                removeTitle: "删除节点",
                renameTitle: "编辑节点名称",
                showRemoveBtn: showRemoveBtn,
                showRenameBtn: showRenameBtn,
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeDrag: beforeDrag,
                beforeEditName: beforeEditName,
                beforeRemove: beforeRemove,
                beforeRename: beforeRename,
                onRemove: onRemove,
                onRename: onRename,
                beforeClick: zTreeBeforeClick,
                onClick: zTreeOnClick,
                beforeDblClick: zTreeBeforeDblClick
            }
        };

        // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
        var zNodes = {$department};

        var className = "dark",
            type = '',
            tempName = '',
            tempId,tempKey,
            currentPage = 1,
            totalCounts = 0;
        function beforeDrag(treeId, treeNodes) {
            return false;
        }
        function zTreeBeforeDblClick(treeId, treeNode) {
            return false;
        }
        function beforeEditName(treeId, treeNode) {
            className = (className === "dark" ? "":"dark");
            // var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            // zTree.selectNode(treeNode);
            // if(treeNode)
            // setTimeout(function() {
            //     zTree.editName(treeNode);
            // }, 0);
            tempName = treeNode.name;
            type = 'edit';
        }
        function beforeRemove(treeId, treeNode) {
            className = (className === "dark" ? "":"dark");

            var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
                temp = false;
            zTree.selectNode(treeNode);
            swal({
                title: "确定要删除该文件夹吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的,我确定!",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        type:"post",
                        url:"{:Url('Resource/folderdel')}",
                        data:{
                            id: treeNode.id
                        },
                        success:function (data) {
                            if(data.code == 1) {
                                zTree.removeNode(treeNode);
                                warning({shortCutFunction:'success',msg:'删除成功'});
                                temp = true;
                            } else {
                                warning({shortCutFunction:'error',msg:data.msg});
                            }
                        },
                        error:function () {
                            warning({shortCutFunction:'error',msg:data.msg});
                        }
                    })
                }
            })
            return temp;
            // return confirm("确认删除该文件夹吗？");
        }
        function onRemove(e, treeId, treeNode) {

        }
        function beforeRename(treeId, treeNode, newName, isCancel) {
            className = (className === "dark" ? "":"dark");
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            if(isCancel) {
                if(type === 'add') {
                    zTree.removeNode(treeNode);
                } else {
                    setTimeout(function() {
                        zTree.cancelEditName();
                    }, 0);
                }

                return true
            }else{
                if (newName.length == 0) {
                    setTimeout(function() {
                        zTree.cancelEditName();
                        warning({msg:"节点名称不能为空."});
                    }, 0);
                    return false;
                }else{
                    if(tempName == newName) {
                        return true;
                    }
                    var pid = treeNode.level == 2 ? treeNode.pId : 0,
                        top_id = treeNode.level == 1 ? treeNode.pId : treeNode.getParentNode().pId;
                    if(type === 'add') {
                        $.ajax({
                            type:"post",
                            url:"{:Url('Resource/folderadd')}",
                            data:{
                                pid: pid,
                                top_id: top_id,
                                name: newName,
                                departmentid: user.departmentid,
                                username: user.username,
                                userid: user.userid,
                            },
                            success:function (data) {
                                if(data.code == 1) {
                                    treeNode.id = parseInt(data.data.id);
                                    treeNode.userid = user.userid;
                                    treeNode.isParent = true;
                                    zTree.updateNode(treeNode);
                                    warning({shortCutFunction:'success',msg:'添加成功'});
                                } else {
                                    zTree.removeNode(treeNode);
                                    warning({shortCutFunction:'error',msg:data.msg});
                                }
                            },
                            error:function () {
                                zTree.removeNode(treeNode);
                                warning({shortCutFunction:'error',msg:data.msg});
                            }
                        })
                    }else if(type === 'edit') {
                        $.ajax({
                            type:"post",
                            url:"{:Url('Resource/folderedit')}",
                            data:{
                                id: treeNode.id,
                                name: newName
                            },
                            success:function (data) {
                                if(data.code == 1) {
                                    warning({shortCutFunction:'success',msg:'修改成功'});
                                } else {
                                    zTree.editName(treeNode);
                                    warning({shortCutFunction:'error',msg:data.msg});
                                }
                            },
                            error:function () {
                                zTree.editName(treeNode);
                                warning({shortCutFunction:'error',msg:data.msg});
                            }
                        })
                    }

                }
            }

        }
        function onRename(e, treeId, treeNode, isCancel) {

        }
        function showRemoveBtn(treeId, treeNode) {
            if(user.permission == 1){
                return treeNode.level > 0;
            } else if (user.permission == 2) {
                if(treeNode.level == 1) {
                    return user.departmentid == treeNode.pId;
                } else if (treeNode.level == 2) {
                    return user.departmentid == treeNode.getParentNode().pId;
                }
            } else {
                if(treeNode.level == 2) {
                    return user.userid == treeNode.userid;
                }
            }
        }
        function showRenameBtn(treeId, treeNode) {
            if(user.permission == 1){
                return treeNode.level > 0;
            } else if (user.permission == 2) {
                if(treeNode.level == 1) {
                    return user.departmentid == treeNode.pId;
                } else if (treeNode.level == 2) {
                    return user.departmentid == treeNode.getParentNode().pId;
                }
            } else {
                if(treeNode.level == 2) {
                    return user.userid == treeNode.userid;
                }
            }
        }
        function zTreeBeforeClick(treeId, treeNode, clickFlag) {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            var selectedNode = zTree.getSelectedNodes()[0];
            if(selectedNode === treeNode) {
                if(treeNode.open) {
                    zTree.expandNode(treeNode);
                } else {
                    zTree.expandNode(treeNode);
                }
                return false;
            }
        }
        function zTreeOnClick(e, treeId, treeNode) {
            $("#myModal").modal({backdrop:'static',keyboard:false});
            $.ajax({
                type:"post",
                url:"{:Url('Resource/file')}",
                data:{
                    folder_id: treeNode.id
                },
                success:function (data) {
                    $("#myModal").modal('hide');
                    if(data.code == 1) {
                        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                        $("#file-list").empty();
                        for(var i in data.data.data) {
                            var html =
                                '<tr>'+
                                '<td>'+data.data.data[i].name+'</td>' +
                                '<td>'+data.data.data[i].file_type+'</td>' +
                                '<td>'+data.data.data[i].upload_time+'</td>' +
                                '<td>'+data.data.data[i].file_size+'</td>';
                            if(treeNode.level > 0 && (user.permission == 1 || (user.permission == 2 && ((treeNode.level == 1 && user.departmentid == treeNode.pId) || (treeNode.level == 2 && user.departmentid != treeNode.getParentNode().pId))) || (user.permission == 3 && treeNode.userid == user.userid))) {
                                html += '<td>' +
                                    '<a data-toggle="modal" class="btn-sm btn-primary edit-file" style="margin-right: 10px;" data-id="'+data.data.data[i].id+'" data-file-id="'+data.data.data[i].file_id+'" data-name="'+data.data.data[i].name+'" data-title="'+data.data.data[i].file_name+'" href="#modal-form"><i class="fa fa-pencil"></i>修改</a>' +
                                    '<a href="/admin/resource/filedel?id='+data.data.data[i].id+'" class="confirm btn-sm btn-danger"><i class="fa fa-trash-o"></i> 删除</a>' +
                                    '</td></tr>';
                            }else{
                                html += '<td>无权限</td></tr>';
                            }
                            $("#file-list").append(html);
                        }
                        if(data.data.count > 0) {
                            totalCounts = data.data.count;
                            setPage(currentPage, Math.ceil(totalCounts/10), getPage);
                        }
                        zTree.expandNode(treeNode, true, false, true);
                    } else {

                        warning({shortCutFunction:'error',msg:data.msg});
                    }
                },
                error:function () {
                    warning({shortCutFunction:'error',msg:data.msg});
                }
            })

        }
        function setPage(pageCurrent, pageSum, callback) {
            $(".pagination").bootstrapPaginator({
                //设置版本号
                bootstrapMajorVersion: 3,
                // 显示第几页
                currentPage: pageCurrent,
                // 总页数
                totalPages: pageSum,
                //当单击操作按钮的时候, 执行该函数, 调用ajax渲染页面
                onPageClicked: function (event,originalEvent,type,page) {
                    // 把当前点击的页码赋值给currentPage, 调用ajax,渲染页面
                    currentPage = page;
                    callback && callback()
                }
            })
        }
        function getPage() {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            var treeNode = zTree.getSelectedNodes()[0];
            $.ajax({
                type:"post",
                url:"{:Url('Resource/file')}",
                data:{
                    folder_id: treeNode.id,
                    page: currentPage,
                },
                success:function (data) {
                    $("#myModal").modal('hide');
                    if(data.code == 1) {
                        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                        $("#file-list").empty();
                        for(var i in data.data.data) {
                            var html =
                                '<tr>'+
                                '<td>'+data.data.data[i].name+'</td>' +
                                '<td>'+data.data.data[i].file_type+'</td>' +
                                '<td>'+data.data.data[i].upload_time+'</td>' +
                                '<td>'+data.data.data[i].file_size+'</td>';
                            if(treeNode.level > 0 && (user.permission == 1 || (user.permission == 2 && ((treeNode.level == 1 && user.departmentid == treeNode.pId) || (treeNode.level == 2 && user.departmentid != treeNode.getParentNode().pId))) || (user.permission == 3 && treeNode.userid == user.userid))) {
                                html += '<td>' +
                                    '<a data-toggle="modal" class="btn-sm btn-primary edit-file" style="margin-right: 10px;" data-id="'+data.data.data[i].id+'" data-name="'+data.data.data[i].name+'" data-title="'+data.data.data[i].file_name+'" href="#modal-form"><i class="fa fa-pencil"></i>修改</a>' +
                                    '<a href="/admin/resource/filedel?id='+data.data.data[i].id+'" class="confirm btn-sm btn-danger"><i class="fa fa-trash-o"></i> 删除</a>' +
                                    '</td></tr>';
                            }else{
                                html += '<td>无权限</td></tr>';
                            }
                            $("#file-list").append(html);
                        }
                        if(totalCounts > 0) {
                            setPage(currentPage, Math.ceil(totalCounts/10), getPage);
                        }
                        zTree.expandNode(treeNode, true, false, true);
                    } else {

                        warning({shortCutFunction:'error',msg:data.msg});
                    }
                },
                error:function () {
                    warning({shortCutFunction:'error',msg:data.msg});
                }
            })
        }

        var newCount = 1;
        function addHoverDom(treeId, treeNode) {
            var sObj = $("#" + treeNode.tId + "_span");
            if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
            var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
                + "' title='添加文件夹' onfocus='this.blur();'></span>";
            if((user.permission ==1 && treeNode.level < 2) || (user.permission == 2 && ((treeNode.level == 1 && user.departmentid == treeNode.pId) || (treeNode.level == 0 && user.departmentid == treeNode.id))) || (user.permission == 3 && (treeNode.level == 1 && user.departmentid == treeNode.pId))){
                sObj.after(addStr);
            }
            var btn = $("#addBtn_"+treeNode.tId);
            if (btn) btn.bind("click", function(){
                var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                zTree.addNodes(treeNode, {id:(1000 + newCount), pId:treeNode.id, name:"新建文件夹" + (newCount++)});
                zTree.editName(treeNode.children[treeNode.children.length - 1]);
                type = 'add';
                return false;
            });
        }
        function removeHoverDom(treeId, treeNode) {
            $("#addBtn_"+treeNode.tId).unbind().remove();
        }
        function selectAll() {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            zTree.setting.edit.editNameSelectAll =  $("#selectAll").attr("checked");
        }

        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            $("#selectAll").bind("click", selectAll);
        });
        $(".add-file").on('click',function () {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            var treeNode = zTree.getSelectedNodes()[0];
            if(!treeNode) {
                warning({shortCutFunction:'error',msg:'请选择相关文件夹'});
                return false;
            }
            if(treeNode.level > 0 && (user.permission == 1 || (user.permission == 2 && ((treeNode.level == 1 && user.departmentid == treeNode.pId) || (treeNode.level == 2 && user.departmentid == treeNode.getParentNode().pId))) || (user.permission == 3 && treeNode.userid == user.userid))) {
                // $("#file").click();
                $("input[name='title']").val('');
                $("#input-file > span").text('');
                fileObj.id = 0;
                type = 'add';
            }else{
                warning({shortCutFunction:'error',msg:'无法在该文件夹下添加文件'});
                return false
            }
        });
        $("input[name='attachment']").on("change",function(value){
            if(typeof value.target.files[0] != 'object') {
                return;
            }
            var size = (value.target.files[0].size / 1024 ).toFixed(2);
            if(size <= 102400){
                var file = value.target.files[0];
                var formData = new FormData();
                formData.append("file",file);
                $.ajax({
                    type:"post",
                    url:"{:Url('File/upload')}",
                    data:formData,
                    // mimeType:"multipart/form-data",
                    processData: false,
                    contentType: false,
                    success:function(msg){
                        var msg = $.parseJSON(msg);
                        if(msg.code == 1) {
                            fileObj = msg.data;
                            $("#input-file > span").text(fileObj.name);
                            $("input[name='attachment']").val('');
                        }else{
                            warning({msg:"上传失败，请重试"});
                        }
                    }
                });
            } else {
                warning({msg:"您选择的文件超过100mb，请重新选择"});
                return;
            }
        });
        $("#addFile").on('click',function () {
            $("input[name='attachment']").click();
        });
        $("#addForm").on('click',function () {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            var treeNode = zTree.getSelectedNodes()[0];
            if(fileObj.id == 0 || !$("input[name='title']").val().trim()) {
                warning({msg:"请输入文件名称并选择相应文件"});
                return false;
            }
            if(type == 'edit') {
                var data = {
                    id:tempId,
                    top_id: treeNode.level == 1?treeNode.pId:treeNode.getParentNode().pId,
                    folder_id: treeNode.id,
                    file_id: fileObj.id,
                    name: $("input[name='title']").val().trim()
                };
                var url = "{:Url('Resource/fileedit')}";
            } else {
                var data = {
                    top_id: treeNode.level == 1?treeNode.pId:treeNode.getParentNode().pId,
                    folder_id: treeNode.id,
                    file_id: fileObj.id,
                    name: $("input[name='title']").val().trim()
                };
                var url = "{:Url('Resource/fileadd')}";
            }
            $.ajax({
                type:"post",
                url:url,
                data:data,
                success:function(msg){
                    if(msg.code == 1) {
                        var html =
                            '<tr>'+
                            '<td>'+msg.data.name+'</td>' +
                            '<td>'+msg.data.file_type+'</td>' +
                            '<td>'+msg.data.upload_time+'</td>' +
                            '<td>'+msg.data.file_size+'</td>';
                        if(treeNode.level > 0 && (user.permission == 1 || (user.permission == 2 && ((treeNode.level == 1 && user.departmentid == treeNode.pId) || (treeNode.level == 2 && user.departmentid != treeNode.getParentNode().pId))) || (user.permission == 3 && treeNode.userid == user.userid))) {
                            html += '<td>' +
                                '<a data-toggle="modal" class="btn-sm btn-primary edit-file" style="margin-right: 10px;" href="#modal-form" data-id="'+msg.data.id+'" data-file-id="'+msg.data.file_id+'" data-name="'+msg.data.name+'" data-title="'+msg.data.file_name+'"><i class="fa fa-pencil"></i>修改</a>' +
                                '<a href="/admin/resource/filedel?id='+msg.data.id+'" class="confirm btn-sm btn-danger"><i class="fa fa-trash-o"></i> 删除</a>' +
                                '</td></tr>';
                        }else{
                            html += '<td>无权限</td></tr>';
                        }
                        if(type == 'edit') {
                            $("#file-list > tr").eq(tempKey).remove();
                        } else {
                            totalCounts ++;
                            setPage(currentPage, Math.ceil(totalCounts/10), getPage);
                        }
                        $("#file-list").prepend(html);
                        $('#modal-form').modal('hide');
                        warning({shortCutFunction:'success',msg:'添加成功'});
                        // document.getElementById("formFile").reset();
                    }
                }
            });
        });
        $(document).on('click','.edit-file',function(){
            $("#modal-title").text('修改文件');
            $("#addFile").text('修改文件');
            $("#addForm").text('修改');
            var id = $(this).attr('data-id'),
                name = $(this).attr('data-name'),
                title = $(this).attr('data-title');
            $("input[name='title']").val(name);
            $("#input-file > span").text(title);
            tempId = id;
            tempKey = $(this).index();
            fileObj.id = $(this).attr('data-file-id');
            type = 'edit';
        });
        $(document).on('click','.btn-danger',function(){
            var _this = this;
            var url = $(_this).attr("href");
            swal({
                title: "你确定要删除该文件吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的!",
                cancelButtonText: "取消",
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    type:"post",
                    url:url,
                    success:function(msg){
                        if(msg.code == 1) {
                            swal({
                                title: "已经删除!",
                                text: "你已经删除了这条数据!",
                                type: "success",
                            }, function(){
                                $(_this).parents('tr').remove();
                            });
                        }else{
                            swal("删除失败!", "请重试!", "error");
                        }
                    }
                });
            });
            return false;
        });

    })
</script>
{/block}
